﻿using System;
using System.Data;
using System.Configuration;


using System.Xml;


namespace common
{
    /// <summary>
    /// ParseXml 的摘要说明
    /// </summary>
    /// 
    public class ParseXml
    {
        XmlDocument doc;
        private string FilePath;
        public ParseXml()
        {
            //
            // TODO: 在此处添加构造函数逻辑
            //
        }


        public ParseXml(string filepath)
        {
            doc = new XmlDocument();
            FilePath = filepath;
            doc.Load(filepath);

        }
        public string parse(string XPath)
        {
            XmlNode x1 = doc.GetElementsByTagName(XPath).Item(0);
            return x1.InnerText;
        }

        public void update(string XPath, string content)
        {
            XmlNode x1 = doc.GetElementsByTagName(XPath).Item(0);
            x1.InnerText = content;
            doc.Save(FilePath);
        }

        public void close()
        {
            doc = null;
        }


        public string bianli()
        {
            XmlNodeList nodeList = doc.SelectSingleNode("contact_us").ChildNodes;
            XmlElement xe = null;
            string s = "";
            foreach (XmlNode xn in nodeList)
            {
                xe = (XmlElement)xn;
                s += xe.InnerText;
            }
            return s;
        }





    }
}